<!DOCTYPE html>
<html>
<head th:include="cultivateWeb/header :: culHeaderCss">
</head>
<link type="text/css" href="/css/cultivateWeb/style/news.css" rel="stylesheet">
<link type="text/css" href="/css/cultivateWeb/style/teach.css" rel="stylesheet">
<body>
<style>
    .left {
        float: left
    }

    .left span {
        font-size: 20px;
    }

    .active1 {
        border-bottom: 2px solid #005C34;
        color: #005C34
    }

    .spanChange:hover {
        cursor: pointer
    }

    .spanChange {
        margin: 0 10px
    }
</style>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header"></header>
<div style="clear: both"></div>
<div style="background-color: #f7f7f7; ">
    <div style="height: 40px">
        <p style="margin: 0px auto auto 380px; line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > 应聘就业</p>
    </div>

    <div style="background-color: #f7f7f7; width: 1200px; margin: 0 auto">
        <div style="margin-bottom: 50px; display: inline-block">
            <!-- 招聘查询 -->
            <section style="" id="zp">
                <div style="margin: 20px auto 20px 60px;line-height: 52px">
                    <div class="left">
                        <span data-type="0" class="active1 spanChange">热门</span>
                        <span data-type="1" class="spanChange">最新</span>
                    </div>
                    <input type="text" id="name" style="margin-left:200px;margin-right: 20px"
                           class="form-control query_1 left" placeholder="请输入岗位关键字"/>
                    <input type="button" onclick="find();" value="搜索" class="but left"/>
                    <div style="clear: both"></div>
                </div>
                <hr style="width: 1190px;margin: auto"/>
                <div style="width: 1200px;margin: auto" id="table"></div>
            </section>

        </div>
    </div>
</div>
<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
<script type="text/javascript" src="/js/xlPaging.js"></script>
</body>
<script>

    function apply(id) {
        ajaxToken("/jzApi/recruitment/addResume", "POST", {id: id}, function (res) {
            layer.confirm("投递成功，请静候佳音！");
        });
    }

    function find() {
        var name = $("#name").val();
        recruit(name, 0)
    }

    $(function () {
        recruit("", 0);
        $(".spanChange").click(function () {
            $(this).addClass("active1");
            $(this).siblings().removeClass("active1");
            recruit("", $(this).attr("data-type"));
        })
    });

    function recruit(name, type) {
        $.ajax({
            url: '/jzApi/recruitment/selJobList',
            data: {
                current: 1,
                number: 10,
                name: name,
                type: type
            },
            success: function (r) {
                var list = r.data.records;
                var table = '';
                list.forEach(function (item, index) {
                    var b = '';
                    if (item.isTop == 1) {
                        b = '<span style="color: #ff552e;font-size: 16px">(置顶)</span>'
                    }
                    if (item.welfareInroduce != '') {
                        if (item.welfareInroduce.length > 20) {
                            item.welfareInroduce = item.welfareInroduce.substring(0, 20) + '...'
                        }
                    }
                    if (item.address != '') {
                        if (item.address.length > 9) {
                            item.address = item.address.substring(0, 9) + '...'
                        }
                    }
                    table += '<div class="zw">' +
                        '<a href="/cultivate/recruitInfo?id=' + item.id + '"><span class="zw_1">' + item.name + '(招' + item.numbers + '人)' + b + '</span>' +
                        '<span class="zw_2">' + item.salaryRange + '/月</span>' +
                        '<span class="zw_3">' +
                        '<span class="zw_4">' + item.address + '</span>' +
                        '<span class="zw_4">' + item.workExperience + '</span>' +
                        '<span class="zw_4">' + item.education + '</span>' +
                        '</span>' +
                        '</div>' +
                        '<div class="gs">' +
                        '<span class="gs_1">' + item.orgName + '</span>' +
                        '<span class="gs_2">' + item.welfareInroduce + '</span>' +
                        '</div>' +
                        '<div></a>' +
                        '<span class="sq">' +
                        '<input type="button" id="apply" onclick="apply(\'' + item.id + '\')" value="申请" class="sqBtn" />' +
                        '<input type="button" id="applyed"  value="已申请" class="sqBtn1" />' +
                        '</span>' +
                        '</div><div style="clear: both"></div>' +
                        '<hr style="width: 1190px;margin: auto"/>';
                });
                table += '<div style="clear: both"></div>';
                $("#table").html(table);
                page(1, r.data.pages, $("#name").val(), type);
            }
        })
    }

    function page(num, tolPages, name, type) {
        $("#page").paging({
            nowPage: Number(num), // 当前页码
            pageNum: Number(tolPages), // 总页码
            buttonNum: 10, //要展示的页码数量
            canJump: 1,// 是否能跳转。0=不显示（默认），1=显示
            showOne: 0,//只有一页时，是否显示。0=不显示,1=显示（默认）
            callback: function (num) { //回调函数
                $.ajax({
                    url: "/jzApi/recruitment/selJobList",
                    type: 'GET',
                    data: {
                        current: num,
                        number: 10,
                        name: name,
                        type: type
                    },
                    success: function (res) {
                        var list = res.data.records;
                        var table = '';
                        list.forEach(function (item, index) {
                            var b = '';
                            if (item.isTop == 1) {
                                b = '<span style="color: #ff552e;font-size: 16px">(置顶)</span>'
                            }
                            if (item.welfareInroduce != '') {
                                if (item.welfareInroduce.length > 20) {
                                    item.welfareInroduce = item.welfareInroduce.substring(0, 20) + '...'
                                }
                            }
                            if (item.address != '') {
                                if (item.address.length > 9) {
                                    item.address = item.address.substring(0, 9) + '...'
                                }
                            }
                            table += '<div class="zw">' +
                                '<a href="/cultivate/recruitInfo?id=' + item.id + '"><span class="zw_1">' + item.name + '(招' + item.numbers + '人)' + b + '</span>' +
                                '<span class="zw_2">' + item.salaryRange + '/月</span>' +
                                '<span class="zw_3">' +
                                '<span class="zw_4">' + item.address + '</span>' +
                                '<span class="zw_4">' + item.workExperience + '</span>' +
                                '<span class="zw_4">' + item.education + '</span>' +
                                '</span>' +
                                '</div>' +
                                '<div class="gs">' +
                                '<span class="gs_1">' + item.orgName + '</span>' +
                                '<span class="gs_2">' + item.welfareInroduce + '</span>' +
                                '</div>' +
                                '<div></a>' +
                                '<span class="sq">' +
                                '<input type="button" id="apply" onclick="apply(\'' + item.id + '\')" value="申请" class="sqBtn" />' +
                                '<input type="button" id="applyed"  value="已申请" class="sqBtn1" />' +
                                '</span>' +
                                '</div><div style="clear: both"></div>' +
                                '<hr style="width: 1190px;margin: auto"/>';
                        });
                        table += '<div style="clear: both"></div>';
                        $("#table").html(table);
                    }
                });
            }
        });
    }
</script>
</html>